package cn.iocoder.yudao.module.system.enums.mail;

import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 用户邮箱验证码发送场景的枚举
 *
 * @author miaoqw
 */
@Getter
@AllArgsConstructor
public enum MailSceneEnum implements IntArrayValuable {

    MEMBER_REGISTER(1, "user-mail-register", "会员用户 - 邮箱注册"),
    MEMBER_UPDATE_MAIL(2, "user-update-mail", "会员用户 - 修改邮箱"),
    MEMBER_UPDATE_PASSWORD(3, "user-update-password", "会员用户 - 修改密码"),
    MEMBER_RESET_PASSWORD(4, "user-reset-password", "会员用户 - 忘记密码"),
    MEMBER_REGISTER_OR_LOGIN(5, "user-mail-register-or-login", "会员用户 - 邮箱注册或登录");

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(MailSceneEnum::getScene).toArray();

    /**
     * 验证场景的编号
     */
    private final Integer scene;
    /**
     * 模版编码
     */
    private final String templateCode;
    /**
     * 描述
     */
    private final String description;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static MailSceneEnum getCodeByScene(Integer scene) {
        return ArrayUtil.firstMatch(sceneEnum -> sceneEnum.getScene().equals(scene),
                values());
    }

}
